import { BasicFetchResult } from '/@/api/model/baseMode';
import { defHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/@/utils/http/axios/types';
import { ExportParams } from './model';
enum Api {
  List = '/baseInfo/sellHousesManager/findPage',
  Delete = '/baseInfo/sellHousesManager/delete', //删除
  Edit = '/baseInfo/sellHousesManager/operate', //上下线
  See = '/baseInfo/sellHousesManager/findById', //查看
  Export = '/baseInfo/sellHousesManager/export', //导出
}

/**
 * @description: 查询二手交易信息
 */
export function ListApi(params, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<BasicFetchResult<any>>(
    {
      url: Api.List,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}

/**
 * @description: 删除
 */
export function DeleteApi(userId: any, mode: ErrorMessageMode = 'modal') {
  return defHttp.get(
    {
      url: Api.Delete + `/${userId}`,
    },
    {
      errorMessageMode: mode,
    }
  );
}

/**
 * @description: 上下线/驳回
 */
export function EditApi(params, mode: ErrorMessageMode = 'modal') {
  return defHttp.post(
    {
      url: Api.Edit,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}

/**
 * @description: 查看
 */
export function DetailsApi(userId: any, mode: ErrorMessageMode = 'modal') {
  return defHttp.get(
    {
      url: Api.See + `/${userId}`,
    },
    {
      errorMessageMode: mode,
    }
  );
}
//区域
export default function region(record) {
  return `${record.province}/${record.area}`;
}
/**
 * @description: 导出
 */
export function ExportApi(params: ExportParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.get(
    {
      url: Api.Export,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
